<?php
	require "../defines.php";
	require "../model/class_Login.php";
	require "../model/class_Admin.php";
	require "../model/class_Item.php";
	require "../model/class_Img.php";
	
		$adm = new Admin();
		$item = new Item();
		$obj = new login();
		$auth=$obj->isAuth();

		if (!$auth){
			header ("Location: ../index.php");
			exit;
		}
		
	if (isset($_POST['addProduct'])){
		$adm->save();
		$f = $_FILES['file'];
		empty($f['name']) ? '' : $img = new Img($f);	// chk if picture is set into form field. If so - instance an Img Object
	}

	$filtr = $adm->filter($ord);
	$all = $adm->product_list($ord);
	
	if (isset ($_GET['del'])){
		$adm->del($_GET['del']);
		header ("Location:" .$_SERVER ["HTTP_REFERER"]);			
		exit;
	}	

	$catFilter = $item->form_filter($cf);
	$frm = $item->getForm($cf, $q);			//Main form (for new and existing products)
?>